package com.tangkun.environment.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tangkun.environment.R;
import com.tangkun.environment.utils.JumpHelper;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 新消息设置
 */
public class XinXiaoXiSheZhiActivity extends BaseActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.iv_xinxiaoxishezhi_xinxiaoxitongzhi)
    ImageView ivXinxiaoxishezhiXinxiaoxitongzhi;
    @BindView(R.id.ll_xinxiaoxishezhi_xinxiaoxitongzhi)
    LinearLayout llXinxiaoxishezhiXinxiaoxitongzhi;
    @BindView(R.id.iv_xinxiaoxishezhi_shengyin)
    ImageView ivXinxiaoxishezhiShengyin;
    @BindView(R.id.ll_xinxiaoxishezhi_shengyin)
    LinearLayout llXinxiaoxishezhiShengyin;
    @BindView(R.id.iv_xinxiaoxishezhi_zhendong)
    ImageView ivXinxiaoxishezhiZhendong;
    @BindView(R.id.ll_xinxiaoxishezhi_zhendong)
    LinearLayout llXinxiaoxishezhiZhendong;
    private Context mContext;

    /**
     * 新消息通知 开启
     */
    private boolean xinxiaoxitongzhiOn = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xinxiaoxishezhi);
        mContext = this;
        ButterKnife.bind(this);
        title.setText("新消息设置");
    }

    @OnClick({R.id.back, R.id.iv_xinxiaoxishezhi_xinxiaoxitongzhi, R.id.iv_xinxiaoxishezhi_shengyin, R.id.iv_xinxiaoxishezhi_zhendong})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back://返回
                JumpHelper.finish(mContext);
                break;
            case R.id.iv_xinxiaoxishezhi_xinxiaoxitongzhi://新消息通知
                initStatus();
                initBtn();
                break;
            case R.id.iv_xinxiaoxishezhi_shengyin://声音
                break;
            case R.id.iv_xinxiaoxishezhi_zhendong://震动
                break;
        }
    }

    /**
     * 刷新状态
     */
    private void initStatus() {
        if (xinxiaoxitongzhiOn) {
            xinxiaoxitongzhiOn = false;
        } else {
            xinxiaoxitongzhiOn = true;
        }
    }

    /**
     * 刷新按钮
     */
    private void initBtn() {
        if (xinxiaoxitongzhiOn) {
            ivXinxiaoxishezhiXinxiaoxitongzhi.setImageResource(R.mipmap.ic_switch_on);
        } else {
            ivXinxiaoxishezhiXinxiaoxitongzhi.setImageResource(R.mipmap.ic_switch_off);
        }
    }
}
